Skip to content

Allow using a pre-authenticated google access token - #231

Open
kesor wants to merge 1 commit into
awslabs:masterfrom
doitintl:feat/pre-auth-goog-tokens
Open

Allow using a pre-authenticated google access token#231
kesor wants to merge 1 commit into
awslabs:masterfrom
doitintl:feat/pre-auth-goog-tokens

Conversation

@kesor

@kesor kesor commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

Description of changes:
Enable using a custom Google client that reuses a pre-authenticated Access Token, thus skipping the complexity of trying to use ssosync with WIF and other methods of authentication and allows to do all of that externally.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kesor
kesor force-pushed the feat/pre-auth-goog-tokens branch from c8dfe11 to a6dc16b Compare June 2, 2026 10:31
Copilot AI review requested due to automatic review settings June 2, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an alternative authentication path in the Google Admin API client that loads an OAuth2 access token from a file specified by the SSOSYNC_ACCESS_TOKEN_FILE environment variable, bypassing the standard service account JWT flow.

Changes:

  • Introduces env-var-driven token file loading for Google Admin client construction.
  • Constructs an oauth2.StaticTokenSource from the file contents and uses it to build the admin service.
  • Falls back to the existing service account JWT flow when the env var is unset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/google/client.go Outdated
Comment on lines +53 to +54
// Allow injecting access token via env var pointing to a file with { "access_token": "...", "expiry": "..." }
if tokenPath := os.Getenv("SSOSYNC_ACCESS_TOKEN_FILE"); tokenPath != "" {
Comment thread internal/google/client.go Outdated
Comment on lines +66 to +71
expiry := time.Now().Add(time.Hour)
if tokenData.Expiry != "" {
if parsedExpiry, err := time.Parse(time.RFC3339, tokenData.Expiry); err == nil {
expiry = parsedExpiry
}
}
Comment thread internal/google/client.go Outdated
Comment on lines +72 to +77
tok := &oauth2.Token{
AccessToken: tokenData.AccessToken,
TokenType: "Bearer",
Expiry: expiry,
}
ts := oauth2.StaticTokenSource(tok)
Comment thread internal/google/client.go Outdated
Comment on lines +53 to +54
// Allow injecting access token via env var pointing to a file with { "access_token": "...", "expiry": "..." }
if tokenPath := os.Getenv("SSOSYNC_ACCESS_TOKEN_FILE"); tokenPath != "" {
@kesor
kesor force-pushed the feat/pre-auth-goog-tokens branch from a6dc16b to ba656ea Compare June 2, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants